package com.android.superobstacleavoider;

import android.content.Context;

import com.android.superobstacleavoider.framework.Audio;
import com.android.superobstacleavoider.framework.Music;
import com.android.superobstacleavoider.framework.Sound;

public class AudioHandler {
	private static Music m_music;
	private static Sound m_ballSound;
	private static Sound m_collide;
	private static Context m_context;

	public static Music getMusic() {
		return m_music;
	}

	public static Sound getBallSound() {
		return m_ballSound;
	}
	
	public static Sound getCollideSound() {
		return m_collide;
	}

	public static void load(Context a_context, Audio a_audio) {
		m_context = a_context;

		m_music = a_audio.newMusic("music.mp3");
		m_music.setLooping(true);
		m_music.setVolume(0.5f);
		playMusic(m_music);
		m_ballSound = a_audio.newSound("shoot.wav");
		m_collide = a_audio.newSound("take_damage.wav");
	}

	public static void reload() {
		//playMusic(m_music);
	}

	public static void playSound(Sound a_sound) {
		// play sound only if not disabled in settings
		if (Prefs.getSound(m_context)) {
			a_sound.play(1);
		}
	}

	public static void playMusic(Music a_music) {
		// play music only if not disabled in settings
		if (Prefs.getMusic(m_context)) {			
			a_music.play();
		}
	}
}
